package com.jiangjiang.eshop.order.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jiangjiang.eshop.order.domain.OrderInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName OrderInfoMapper
 * @Description TODO
 * @Author jhw
 * @Date 2021/7/24 11:36
 * @Version 1.0
 **/
@Mapper
public interface OrderInfoMapper extends BaseMapper<OrderInfoEntity> {
    /**
     * 查询确认收货时间超过了7天而且还没有发表评论的订单
     * @return
     */
    @Select("SELECT "
            + "id,"
            + "order_no,"
            + "consignee,"
            + "delivery_address,"
            + "consignee_cell_phone_number,"
            + "total_amount,"
            + "discount_amount,"
            + "coupon_amount,"
            + "freight,"
            + "payable_amount,"
            + "pay_type,"
            + "invoice_title,"
            + "taxpayer_id,"
            + "order_status,"
            + "user_account_id,"
            + "username,"
            + "order_comment,"
            + "is_published_comment,"
            + "confirm_receipt_time,"
            + "gmt_create,"
            + "gmt_modified "
            + "FROM order_info "
            + "WHERE DATEDIFF(NOW(),IFNULL(confirm_receipt_time,NOW())) > 7 "
            + "AND is_published_comment=0"
    )
    List<OrderInfoEntity> listNotPublishedCommentOrders();

}
